<!-- 库存销售 -->
<template>
    <div>
        <el-button :disabled="disabled" @click="handleQuery">
            库存销售
        </el-button>
        <el-dialog draggable v-model="dialogTableVisible" title="库存销售信息" width="75%">
            <el-table :data="gridData" max-height="400">
                <el-table-column property="factoryCode" label="工厂"/>
                <el-table-column property="inventoryAdd" label="库位"/>
                <el-table-column align="center" label="周销">
                    <el-table-column property="lastweekWeeklySales" label="上周周销"/>
                    <el-table-column property="last4WeekAverageWeeklySales" label="近四周平均周销"/>
                </el-table-column>
                <el-table-column property="transitQuantity" label="在途数量（台）"/>
                <el-table-column property="turnoverWeeksInclPurTransit" label="周转数（含采购在途）"/>
                <el-table-column property="turnoverWeeksInclPurTransitCurrentPur" label="周转数（含采购在途+本次采购）"/>
                <el-table-column align="center" label="库存">
                    <el-table-column property="provWhseInventory" label="省仓库存"/>
                    <el-table-column property="cargoWhseInventory" label="铺货仓库存"/>
                    <el-table-column property="totalWhseInventory" label="小计"/>
                </el-table-column>
                <el-table-column property="materialDesc" label="物料描述" min-width="180" show-overflow-tooltip/>
                <el-table-column property="materialCode" label="物料编号" min-width="160" show-overflow-tooltip/>
            </el-table>
        </el-dialog>
    </div>
</template>

<script setup>
import {getCurrentInstance, ref} from 'vue'
import {doGet} from '@/config/http'
import {echoMaterialdes} from "@/utils/echoDescription";

const {proxy} = getCurrentInstance();

const dialogTableVisible = ref(false)

const gridData = ref([])
const props = defineProps({
    params: Object,
    disabled: {
        type: Boolean,
        default: false
    }
});
const svc = ref('peas-module-plan-biz')

function handleQuery() {
    if (!props.params) {
        proxy.$alert('请选择需要查询库存信息的记录', "提示", {type: 'warning'})
        return false
    }
    doGet(svc.value, '/req/query-material-weekly-sales-turn-over', props.params).then(res => {
        gridData.value = res.filter(item => item.inventoryAdd)
        dialogTableVisible.value = true
        echoMaterialdes(gridData.value, ['materialCode'], ['materialDesc'])
    }).catch(e => {
        console.error(e)
    })
}
</script>
<style scoped>
.el-button--text {
    margin-right: 15px;
}

.el-select {
    width: 300px;
}

.el-input {
    width: 300px;
}

.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>
